package com.touzhijia.scheduler.controller;

import com.touzhijia.common.controller.BaseController;
import com.touzhijia.common.persistence.Page;
import com.touzhijia.scheduler.service.TriggerLogService;
import com.touzhijia.scheduler.vo.request.TriggerLogQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 作者：lizw <br/>
 * 创建时间：2017/6/2 10:51 <br/>
 */
@Controller
@RequestMapping(value = "/quartz/triggerLog")
public class TriggerLogController extends BaseController {

    @Autowired
    private TriggerLogService qrtzTriggerLogService;

//    @RequestMapping("/TriggerLog" + VIEW_PAGE_SUFFIX)
//    public ModelAndView getTriggerLogJsp(HttpServletRequest request, HttpServletResponse response) {
//        return new ModelAndView(QuartzJspUrlPath.TriggerLog);
//    }

    @RequestMapping("/findTriggerLogByPage")
    @ResponseBody
    public Object findTriggerLogByPage(HttpServletRequest request,
                                       HttpServletResponse response,
                                       @Valid TriggerLogQueryVo triggerLogQueryVo,
                                       BindingResult bindingResult) {
        return qrtzTriggerLogService.findByPage(
                new Page<>(request, response),
                triggerLogQueryVo.getSchedulerName(),
                triggerLogQueryVo.getInstanceName(),
                triggerLogQueryVo.getTriggerGroup(),
                triggerLogQueryVo.getTriggerName(),
                triggerLogQueryVo.getJobGroup(),
                triggerLogQueryVo.getJobName(),
                triggerLogQueryVo.getJobClassName(),
                triggerLogQueryVo.getStartTimeByStart(),
                triggerLogQueryVo.getStartTimeByEnd(),
                triggerLogQueryVo.getProcessTimeByMin(),
                triggerLogQueryVo.getProcessTimeByMax());
    }

}
